package edu.cn.neusoft.dm.showweb.controller

import com.alibaba.fastjson.JSON
import edu.cn.neusoft.dm.showweb.bean.dealform.user.login.LoginRequest
import edu.cn.neusoft.dm.showweb.service.UserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import javax.servlet.http.HttpServletRequest

/**
 * author:纷羽
 * create at 2018/7/13
 */
@Controller
@RequestMapping(value = ["api/user"], produces = ["application/json;charset=utf-8"])
class UserController {

    @Autowired
    private lateinit var userService: UserService

    @RequestMapping("login")
    @ResponseBody
    fun login(@RequestBody requset: LoginRequest, req: HttpServletRequest): String {
        val resp = userService.login(requset)
        return JSON.toJSONString(resp)
    }
}